package cn.wolfcode.wolf2w.util;

import cn.wolfcode.wolf2w.exception.LogicException;
import org.springframework.util.StringUtils;

/**
 * 断言工具类，对传入的参数进行判断
 */
public class AssertUtils {

    /**
     * 判断参数是否有值，没有，抛出异常msg
     * @param param 参数
     * @param msg 异常信息
     */
    public static void hasLength(String param,String msg){
        if(!StringUtils.hasLength(param)){
            throw new LogicException(msg);
        }
    }

    // 判断两个值是否相等
    public static void isEqual(String value1,String value2,String msg){
        if(value1 == null || value2 == null){
            throw new LogicException("传入的参数不能为空！");
        }

        if (!value1.equals(value2)){
            throw new LogicException(msg);
        }
    }
}
